package org.example.carsystem.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.carsystem.domain.SysOperLog;
import org.example.carsystem.mapper.SysOperLogMapper;
import org.example.carsystem.service.SysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Service
public class SysOperLogServiceImpl implements SysOperLogService {
    @Autowired
    SysOperLogMapper sysOperLogMapper;
    public PageInfo<SysOperLog> selectAll(@RequestBody SysOperLog sysOperLog, Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<SysOperLog> sysOperLogs = sysOperLogMapper.selectAll(sysOperLog);
        return new PageInfo<SysOperLog>(sysOperLogs);
    }

    @Override
    public int del(List<Integer> list) {
        return sysOperLogMapper.del(list);
    }

    @Override
    public void saveOrupdate(SysOperLog sysOperLog) {
        if (sysOperLog.getOperId()!=null){
          sysOperLogMapper.update(sysOperLog);
        }
        sysOperLogMapper.insert(sysOperLog);
    }
}
